package com.psy.counseling.controller;


import com.psy.counseling.entity.Role;
import com.psy.counseling.service.impl.RoleServiceImpl;
import com.psy.counseling.vo.DeleteVO;
import com.psy.counseling.vo.PageVO;
import com.psy.counseling.vo.ResultVo;
import com.psy.counseling.vo.RolePermissionVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 梁学儒
 * @since 2022-05-31
 */
@RestController
@RequestMapping("/api/role")
public class RoleController {
    @Resource
    private RoleServiceImpl roleService;

    @PostMapping("/addRole")
    public ResultVo addRole(@RequestBody Role role) {
        return roleService.addRole(role);
    }

    @DeleteMapping("/deleteRole")
    public ResultVo addRole(@RequestBody DeleteVO deleteVO) {
        return roleService.deleteRole(deleteVO);
    }

    @GetMapping("/getRole")
    public ResultVo getRole(Role role, PageVO page) {
        return roleService.listRoles(role,page);
    }

    @PostMapping("/updateRole")
    public ResultVo updateRole(@RequestBody Role role) {
        return roleService.updateRole(role);
    }

    @PostMapping("/updateRolePermission")
    public ResultVo updateRolePermission(@RequestBody RolePermissionVo rolePermissionVo) {
        return roleService.updateRolePermission(rolePermissionVo);
    }
}

